﻿@using NITASA.Data
@using GridMvc.Html
@{
    ViewBag.Title = "Backups";
    //List<string> BackupList = Directory.GetFiles(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["backupDir"]), "*.zip").ToList();
    List<FileInfo> BackupList = new DirectoryInfo(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["backupDir"])).GetFiles().Where(x => x.Extension.ToLower() == ".zip").ToList();
}
<div class="main-content">
    <div class="container-fluid padded">
        @if (TempData["SuccessMessage"] != null)
        {
            <div class="alert alert-success">
                <button class="close" data-dismiss="alert" type="button">×</button>
                @TempData["SuccessMessage"]
            </div>
        }
        @if (TempData["ErrorMessage"] != null)
        {
            <div class="alert alert-error">
                <button class="close" data-dismiss="alert" type="button">×</button>
                @TempData["ErrorMessage"]
            </div>
        }
        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-header">
                        <span class="title">Database Backup</span>
                        <ul class="box-toolbar">
                            <li>
                                @using (Html.BeginForm("Add", "BackupRestore", FormMethod.Post))
                                {
                                    <button type="submit" class="btn btn-blue btn-small"><i class="icon icon-plus icon"  ></i> &nbsp;Take New Backup</button>

                                }
                            </li>
                        </ul>
                    </div>
                    <div class="box-content">
                        @if (BackupList.Count() > 0)
                        {
                            @Html.Grid(BackupList).Columns(columns =>
                            {
                                columns.Add(x => x.Name).SetWidth(750).Titled("Backup Name").Sortable(true).Filterable(true);
                                columns.Add(x => x.CreationTime).Titled("Backup On").Sortable(true).Filterable(true);
                                columns.Add().SetWidth(140).Encoded(false).Sanitized(false).RenderValueAs(x =>
                                @Html.Raw("<a href='/backup/script/" + x.Name + "' target='_blank' class='btn btn-small btn-green'>Download</a>") + " " +
                                @Html.ActionLink("Delete", "Delete", "BackupRestore", new { guid = Path.GetFileNameWithoutExtension(x.FullName) }, new { @class = "btn btn-small btn-red", onclick = "return confirm('Are you sure to delete this Backup ?');" }));
                            }).WithPaging(10,5).WithMultipleFilters()
                        }
                        else
                        {
                            <div class="padded">No Backup set created yet, create the first backup now.</div>
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="modal-confirm" class="modal hide fade" style="width: 370px;">
    <div class="modal-header">
        <a class="close modal_Delete_icon_link" data-dismiss="modal" href="">
            <i class="icon-remove-sign modal_close_icon_fontsize"></i>
        </a>
        <h6 id="H1">Confirmation</h6>
    </div>
    <div class="modal-body">
        <table class="width100per">
            <tr>
                <td id="delete-msg">
                    Are you sure you want to delete this caetgory ?
                </td>
            </tr>
            <tr>
                <td align="right">
                    @Html.ActionLink("Delete", "Delete", "Category", new { id = "dltCat", @class = "btn btn-red" })
                </td>
            </tr>
        </table>
    </div>
</div>

<script type="text/javascript">

</script>


